package cn.lingyangwl.agile.misc.statistic.service;

import cn.lingyangwl.agile.misc.statistic.mapper.*;
import cn.lingyangwl.agile.misc.statistic.model.entity.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author shenguangyang
 */
@Service
public class StatDayRecordServiceImpl extends ServiceImpl<StatDayRecordMapper, StatDayRecord>
    implements StatDayRecordService {
    @Override
    public void saveData(String groupFieldValue, LocalDateTime nowDate, List<StatDayRecord> record) {
        LambdaQueryWrapper<StatDayRecord> lqw = StatDayRecord.lqw()
            .eq(StatDayRecord::getTerminal, groupFieldValue)
            .eq(StatDayRecord::getStatDate, nowDate.toLocalDate());
        this.remove(lqw);
        this.saveBatch(record);
    }
}
